Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2MiniBase = require("MiniBase");
var $2ServerConfig = require("ServerConfig");
var $2EventCenter = require("EventCenter");
var $2QQ_InterstitialMgr = require("QQ_InterstitialMgr");
var $2EventDefine = require("EventDefine");
var $2Platformconf = require("Platformconf");
var $2QQ_VideoMgr = require("QQ_VideoMgr");
var $2QQ_BannerMgr = require("QQ_BannerMgr");
var $2QQ_Share = require("QQ_Share");
var $2QQ_BlockAd = require("QQ_BlockAd");
exports.default = /* */function (_o$default2) {
  function _class22() {
    var _this71;
    babel_classCallCheck(this, _class22);
    _this71 = _callSuper(this, _class22);
    _this71.key_maxDistance = "maxDistance";
    _this71.key_countDistance = "countDistance";
    _this71.loadingShow = false;
    _this71.getSystemInfo = function () {};
    _this71.active = !!window.qq;
    window.qq && window.qq.showShareMenu({
      withShareTicket: true
    });
    console.log("QQ小游戏");
    return _this71;
  }
  babel_inherits(_class22, _o$default2);
  return babel_createClass(_class22, [{
    key: "init",
    value: function init(e) {
      if (window.qq && window.qq.eqapi) {
        var _t39 = $2Platformconf.default.eqconfig();
        _t39.onLoginned = e;
        _t39.getToken = "getToken";
        window.qq.eqapi.init(_t39);
        console.log("=======================config:", _t39);
      }
      $2QQ_InterstitialMgr.default.Instance.init();
      var t = window.qq.getLaunchOptionsSync();
      $2EventCenter.default.postWaitEvent($2EventDefine.default.EVENT_ONSHOW, t);
      window.qq.onShow(function (e) {
        $2EventCenter.default.postWaitEvent($2EventDefine.default.EVENT_ONSHOW, e);
      });
      window.qq.onHide(function (e) {
        $2EventCenter.default.postWaitEvent($2EventDefine.default.EVENT_ONHIDE, e);
      });
      this.updateVersion();
      this.eqInit();
    }
  }, {
    key: "updateVersion",
    value: function updateVersion() {
      if (window.qq && window.qq.getUpdateManager) {
        var _e36 = window.qq.getUpdateManager();
        _e36.onCheckForUpdate(function (t) {
          if (t.hasUpdate) {
            _e36.onUpdateReady(function () {
              window.qq.showModal({
                title: "更新提示",
                content: "新版本已经准备好，是否重启应用？",
                success(t) {
                  if (t.confirm) {
                    console.log("走了该走的地方！");
                    _e36.applyUpdate();
                  } else {
                    console.log("走这里了吗？");
                  }
                }
              });
            });
            _e36.onUpdateFailed(function () {
              window.qq.showModal({
                title: "发现新版本",
                content: "请删除当前小程序，重新搜索打开..."
              });
            });
          }
        });
      }
    }
  }, {
    key: "updateGame",
    value: function updateGame() {
      window.qq && window.qq.getUpdateManager && window.qq.getUpdateManager().applyUpdate();
    }
  }, {
    key: "onUpdateReady",
    value: function onUpdateReady(e) {
      if (window.qq && window.qq.getUpdateManager) {
        var _e37 = window.qq.getUpdateManager();
        _e37.onUpdateReady(function () {
          window.qq.showModal({
            title: "更新提示",
            content: "新版本已经准备好，是否立即使用？",
            success(t) {
              t.confirm && _e37.applyUpdate();
            }
          });
        });
      }
    }
  }, {
    key: "setClipboardData",
    value: function setClipboardData(e) {
      window.qq.setClipboardData && window.qq.setClipboardData({
        data: e,
        success() {},
        fail(e) {
          console.log("setClipboardData调用失败", e);
        }
      });
    }
  }, {
    key: "eqInit",
    value: function eqInit() {
      window.qq.eqRegisterHandler(function (e) {
        $2ServerConfig.default.getInstance().init(e);
      });
    }
  }, {
    key: "eqIsAuthoried",
    value: function eqIsAuthoried() {
      return window.qq.eqIsAuthoried();
    }
  }, {
    key: "checkFollowAwemeState",
    value: function checkFollowAwemeState(e) {
      if (window.qq && window.qq.checkFollowAwemeState) {
        window.qq.checkFollowAwemeState({
          success(t) {
            console.log("---- check success, res:", t);
            var n = t.hasFollowed;
            e(undefined === n || n);
          },
          fail(t) {
            e(false);
            console.log("---- check fail,", t);
          },
          complete() {}
        });
      } else {
        e(true);
      }
    }
  }, {
    key: "openAwemeUserProfile",
    value: function openAwemeUserProfile(e) {
      if (window.qq && window.qq.openAwemeUserProfile) {
        window.qq.openAwemeUserProfile({
          success(t) {
            console.log("---- open success, res: ", t);
            var n = t.hasFollowed;
            e(undefined === n || n);
          },
          fail(e) {
            e.errMsg && e.errMsg.indexOf("login");
            console.log("---- open fail, err: ", e);
          },
          complete() {}
        });
      } else {
        e(true);
      }
    }
  }, {
    key: "shareAppMessage",
    value: function shareAppMessage(e, t) {
      $2QQ_Share.default.getInstance().share();
    }
  }, {
    key: "play_AD",
    value: function play_AD(e, t) {
      t = t ? $2Platformconf.default.Instance.getconfig().QQGame.video[t] : $2Platformconf.default.Instance.getconfig().QQGame.video[0];
      $2QQ_VideoMgr.default.Instance.playvideo(t, e);
    }
  }, {
    key: "showLoading",
    value: function showLoading(e) {
      var _this72 = this;
      if (0 == this.loadingShow) {
        this.loadingShow = true;
        window.qq.showLoading({
          title: "请求中，请稍后...",
          success(e) {
            console.log("".concat(e));
          },
          fail() {
            _this72.loadingShow = false;
            console.log("showLoading调用失败");
          }
        });
      }
    }
  }, {
    key: "hideLoading",
    value: function hideLoading() {
      var _this73 = this;
      1 == this.loadingShow && window.qq.hideLoading({
        success() {
          _this73.loadingShow = false;
          console.log("hideLoading调用成功");
        },
        fail() {
          console.log("hideLoading调用失败");
        }
      });
    }
  }, {
    key: "vibrate",
    value: function vibrate() {
      var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
      if (e) {
        wx.vibrateShort();
      } else {
        wx.vibrateLong();
      }
    }
  }, {
    key: "createImage",
    value: function createImage(e, t) {
      var n = wx.createImage();
      n.onload = function () {
        t(n);
      };
      n.src = e;
    }
  }, {
    key: "getTargetId",
    value: function getTargetId() {
      var e = wx.getLaunchOptionsSync();
      var t = e.query.supportId;
      var n = e.query.targetID;
      e.query.level;
      console.log(">>>>>>>>>>>>>>>>>:" + JSON.stringify(e));
      console.log(" supportId: " + t);
      console.log(" shareId: " + n);
      e.scene;
    }
  }, {
    key: "onPostMessage",
    value: function onPostMessage(e) {
      console.log("onPostMessage");
      wx.getOpenDataContext().postMessage(e);
    }
  }, {
    key: "loginCallBack",
    value: function loginCallBack() {
      this.getTargetId();
    }
  }, {
    key: "request",
    value: function request(e, t, n) {
      wx.request({
        url: e,
        method: "POST",
        data: t,
        success(e) {
          n && n(e);
        },
        fail(e) {
          n && n(e);
        }
      });
    }
  }, {
    key: "interstitialShow",
    value: function interstitialShow(e) {
      var t = "";
      t = e ? $2Platformconf.default.Instance.getconfig().QQGame.banner[e] : $2Platformconf.default.Instance.getconfig().QQGame.banner[0];
      $2QQ_InterstitialMgr.default.Instance.show(t);
    }
  }, {
    key: "bannerDestroy",
    value: function bannerDestroy(e) {
      $2QQ_BannerMgr.default.Instance.Destroy(this.getbannerid(e));
    }
  }, {
    key: "bannerCreate",
    value: function bannerCreate(e, t) {
      $2QQ_BannerMgr.default.Instance.Create(this.getbannerid(e), t);
    }
  }, {
    key: "bannerrefreshAD",
    value: function bannerrefreshAD(e, t) {
      $2QQ_BannerMgr.default.Instance.refreshAD(this.getbannerid(e), t);
    }
  }, {
    key: "bannerShow",
    value: function bannerShow(e, t) {
      $2QQ_BannerMgr.default.Instance.Show(this.getbannerid(e), t);
    }
  }, {
    key: "bannerHide",
    value: function bannerHide(e) {
      $2QQ_BannerMgr.default.Instance.Hide(this.getbannerid(e));
    }
  }, {
    key: "bannertempHide",
    value: function bannertempHide() {
      $2QQ_BannerMgr.default.Instance.tempHide();
    }
  }, {
    key: "bannertempShow",
    value: function bannertempShow() {
      $2QQ_BannerMgr.default.Instance.tempShow();
    }
  }, {
    key: "getbannerid",
    value: function getbannerid(e) {
      if (e) {
        return $2Platformconf.default.Instance.getconfig().QQGame.banner[e];
      } else {
        return $2Platformconf.default.Instance.getconfig().QQGame.banner[0];
      }
    }
  }, {
    key: "blockADshow",
    value: function blockADshow(e, t) {
      e || (e = $2Platformconf.default.Instance.getconfig().QQGame.blockAd[0]);
      $2QQ_BlockAd.default.getInstance().show(e, t);
    }
  }, {
    key: "blockADhide",
    value: function blockADhide(e) {
      e || (e = $2Platformconf.default.Instance.getconfig().QQGame.blockAd[0]);
      $2QQ_BlockAd.default.getInstance().hide();
    }
  }]);
}($2MiniBase.default);